package com.android.justcook;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import camp.android.justcook.R;

public class CategoryListAdapter extends BaseAdapter {
	private final LayoutInflater inflater;
	private final String[] categories;
	private final int[] images;
	public CategoryListAdapter(LayoutInflater inflater, String[] categories, int[] images) {
		this.inflater = inflater;
		this.categories = categories;
		this.images = images;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return categories.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return categories[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		View item = inflater.inflate(R.layout.category_item, parent, false);
		((TextView)item.findViewById(R.id.category_text)).setText(categories[position]);
		((ImageView)item.findViewById(R.id.category_image)).setBackgroundResource(images[position]);
		((ImageView)item.findViewById(R.id.category_image)).getLayoutParams().height=210;

		return item;
	}

}
